<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>代码高亮显示行号Demo</title>
<!-- 导入需要的包 -->
<link rel="stylesheet" href="./highlight/styles/dark.min.css">
<script src="./highlight/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlightjs-line-numbers.js/2.8.0/highlightjs-line-numbers.min.js"></script>
<style>
   body {
        font-family: "Microsoft YaHei", "微软雅黑", "黑体", "宋体", "arial" !important;
        color: #333;
        background-color: #f5f5f5;
        margin: 0;
        padding: 0;
    }
    
    pre>code {
        font-family: 'Consolas'
    }

    .content {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    
    .content pre {
        width: 680px;
    }
</style>
</head>

<body>
    <div class="content">
        <div>
            <h2>java代码</h2>
        <pre>
            <!-- class="java" 也可以不加，会自动识别，但会有点差别 -->
            <code class="java">    @Test
    void testGetAll(){
        List<Stu> stus = stuService.queryAllStu();
        stus.forEach(e -> {
            System.out.println(e);
        });
    }   
    
            </code>
        </pre>
        </div>
        <div>
            <h2>C#代码</h2>
        <pre>
            <code>    //在panel中打开指定窗体，调用该方法时，只需传入一个窗体对象即可
    private void OpenFrm(Form frm)
    {
        frm.TopLevel = false;//取消非顶级窗体
        frm.WindowState = FormWindowState.Maximized;//将窗体最大化
        frm.FormBorderStyle = FormBorderStyle.None;//设为无边框
        frm.Parent = this.palParent;//指定该窗体的父窗体
        frm.Show();//展示窗体
    }
            </code>
        </pre>
        </div>
    </div>
    <script>
    	// 开启代码高亮
        hljs.initHighlightingOnLoad();
        // 行号显示
        hljs.initLineNumbersOnLoad ({ singleLine:true });
    </script>

</body>

</html>
